
# 搜索二维矩阵（二分法）

class Solution:

    def searchMatrix(self, matrix: list[list[int]], target: int) -> bool:
        m, n = len(matrix) - 1, len(matrix[0]) - 1

        i = m
        j = 0
        # for i 
        while i >= 0  and j <= n:

            if matrix[i][j] == target:

                return True
            
            elif matrix[i][j] < target:
                j += 1
            
            else:
                i -= 1
        
        return False
            


